package com.myk.game.heroscuffle.game;

public class HeroMind {

    private final Hero hostHero;
    public AttackedSelector attackedSelector;

    public HeroMind(Hero hostHero) {
        this.hostHero = hostHero;
    }

    /**
     * 设置默认的普攻目标选择器
     */
    public void setDefaultAttackedSelector() {
        attackedSelector = () -> {
            boolean isOnlyOneChoice = hostHero.game.pool.getAliveCount() == 2; //只剩下一个目标了（另外一个是自己）
            Hero other = hostHero.game.pool.getAnyoneAliveHero(hostHero); //随机选择一个非自己的目标
            if (isOnlyOneChoice) {//只剩下一个对手时
                return new Attacked(other, "别无它选径直攻击");
            }
            else {
                return new Attacked(other, "漫无目的随机攻击");
            }
        };
    }

    /**
     * 设置自定义的普攻目标选择器
     */
    public void setCustomAttackedSelector(AttackedSelector attackedSelector) {
        this.attackedSelector = attackedSelector;
    }

    /**
     * 普攻目标选择接口定义
     */
    public interface AttackedSelector {
        /**
         * 默认的雄选择普攻目标
         */
        Attacked onAutoSelectAttacked();
    }
}
